/*
 * Copyright 2021 by LunaSec (owned by Refinery Labs, Inc)
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 */
/**
 * Surprisingly, <style> element can be appended to <input> and <textarea>
 * so we can support ::placeholder, and ::selection even for them.
 */
import { SupportedElementTagName } from './types';

export const SUPPORTED_PSEUDO_SELECTORS = [
  '::after',
  '::before',
  '::first-letter',
  '::first-line',
  '::marker',
  '::placeholder',
  '::selection',
];

export const REPLACED_ELEMENTS: SupportedElementTagName[] = [
  'iframe',
  'video',
  'embed',
  'img',
  'audio',
  'option',
  'canvas',
  'object',
  // 'applet', TODO: No idea why this broke, I think they took it out of the typings for the DOM
];

export const VOID_ELEMENTS: SupportedElementTagName[] = [
  'area',
  'base',
  'br',
  'col',
  'embed',
  'hr',
  'img',
  'input',
  'link',
  'meta',
  'param',
  'source',
  'track',
  'wbr',
];

export const PARENT_ELEMENT_STYLE_ATTRIBUTES = [
  'align-self',
  'block-size',
  'bottom',
  'flex',
  'flex-grow',
  'flex-shrink',
  'height',
  'left',
  'max-block-size',
  'max-height',
  'max-inline-size',
  'max-width',
  'margin',
  'margin-block-end',
  'margin-block-start',
  'margin-bottom',
  'margin-inline-end',
  'margin-inline-start',
  'margin-left',
  'margin-right',
  'margin-top',
  'min-height',
  'min-width',
  // Note: Disabling passing position style data because it breaks elements with a default height of 0.
  'position',
  'right',
  'top',
  'vertical-align',
  'width',
];

export const ELEMENT_ATTRIBUTE_WHITELIST = [
  'align-content',
  'align-items',
  'appearance',
  'backface-visibility',
  'background-attachment',
  'background-blend-mode',
  'background-clip',
  'background-color',
  'background-image',
  'background-origin',
  'background-position',
  'background-position-x',
  'background-position-y',
  'background-repeat',
  'background-size',
  'border-block-end-color',
  'border-block-end-style',
  'border-block-end-width',
  'border-block-start-color',
  'border-block-start-style',
  'border-block-start-width',
  'border-bottom-color',
  'border-bottom-left-radius',
  'border-bottom-right-radius',
  'border-bottom-style',
  'border-bottom-width',
  'border-collapse',
  'border-end-end-radius',
  'border-end-start-radius',
  'border-image-outset',
  'border-image-repeat',
  'border-image-slice',
  'border-image-source',
  'border-image-width',
  'border-inline-end-color',
  'border-inline-end-style',
  'border-inline-end-width',
  'border-inline-start-color',
  'border-inline-start-style',
  'border-inline-start-width',
  'border-left-color',
  'border-left-style',
  'border-left-width',
  'border-right-color',
  'border-right-style',
  'border-right-width',
  'border-spacing',
  'border-start-end-radius',
  'border-start-start-radius',
  'border-top-color',
  'border-top-left-radius',
  'border-top-right-radius',
  'border-top-style',
  'border-top-width',
  'box-decoration-break',
  'box-shadow',
  'box-sizing',
  'break-after',
  'break-before',
  'break-inside',
  'caption-side',
  'caret-color',
  'clear',
  'clip',
  'clip-path',
  'clip-rule',
  'color',
  'color-adjust',
  'color-interpolation',
  'color-interpolation-filters',
  'column-count',
  'column-fill',
  'column-gap',
  'column-rule-color',
  'column-rule-style',
  'column-rule-width',
  'column-span',
  'column-width',
  'contain',
  'content',
  'counter-increment',
  'counter-reset',
  'counter-set',
  'cursor',
  'direction',
  'dominant-baseline',
  'fill',
  'fill-opacity',
  'fill-rule',
  'filter',
  'flood-color',
  'flood-opacity',
  'font-family',
  'font-feature-settings',
  'font-kerning',
  'font-language-override',
  'font-optical-sizing',
  'font-size',
  'font-size-adjust',
  'font-stretch',
  'font-style',
  'font-synthesis',
  'font-variant',
  'font-variant-alternates',
  'font-variant-caps',
  'font-variant-east-asian',
  'font-variant-ligatures',
  'font-variant-numeric',
  'font-variant-position',
  'font-variation-settings',
  'font-weight',
  'hyphens',
  'image-orientation',
  'image-rendering',
  'ime-mode',
  'inline-size',
  'inset-block-end',
  'inset-block-start',
  'inset-inline-end',
  'inset-inline-start',
  'letter-spacing',
  'lighting-color',
  'line-break',
  'line-height',
  'list-style-image',
  'list-style-position',
  'list-style-type',
  'marker-end',
  'marker-mid',
  'marker-start',
  'mask',
  'mask-clip',
  'mask-composite',
  'mask-image',
  'mask-mode',
  'mask-origin',
  'mask-position',
  'mask-position-x',
  'mask-position-y',
  'mask-repeat',
  'mask-size',
  'mask-type',
  'mix-blend-mode',
  'object-fit',
  'object-position',
  'offset-anchor',
  'offset-distance',
  'offset-path',
  'offset-rotate',
  'order',
  'outline-color',
  'outline-offset',
  'outline-style',
  'outline-width',
  'overflow',
  'overflow-anchor',
  'overflow-block',
  'overflow-inline',
  'overflow-wrap',
  'overflow-x',
  'overflow-y',
  'overscroll-behavior-block',
  'overscroll-behavior-inline',
  'overscroll-behavior-x',
  'overscroll-behavior-y',
  'padding-block-end',
  'padding-block-start',
  'padding-bottom',
  'padding-inline-end',
  'padding-inline-start',
  'padding-left',
  'padding-right',
  'padding-top',
  'page-break-after',
  'page-break-before',
  'perspective',
  'perspective-origin',
  'pointer-events',
  'quotes',
  'r',
  'resize',
  'rotate',
  'row-gap',
  'ruby-align',
  'ruby-position',
  'scale',
  'scroll-behavior',
  'scroll-margin-block-end',
  'scroll-margin-block-start',
  'scroll-margin-bottom',
  'scroll-margin-inline-end',
  'scroll-margin-inline-start',
  'scroll-margin-left',
  'scroll-margin-right',
  'scroll-margin-top',
  'scroll-padding-block-end',
  'scroll-padding-block-start',
  'scroll-padding-bottom',
  'scroll-padding-inline-end',
  'scroll-padding-inline-start',
  'scroll-padding-left',
  'scroll-padding-right',
  'scroll-padding-top',
  'scroll-snap-align',
  'scroll-snap-type',
  'scrollbar-color',
  'scrollbar-width',
  'shape-image-threshold',
  'shape-margin',
  'shape-outside',
  'shape-rendering',
  'stop-color',
  'stop-opacity',
  'stroke',
  'stroke-dasharray',
  'stroke-dashoffset',
  'stroke-linecap',
  'stroke-linejoin',
  'stroke-miterlimit',
  'stroke-opacity',
  'stroke-width',
  'text-align',
  'text-align-last',
  'text-anchor',
  'text-combine-upright',
  'text-decoration',
  'text-decoration-color',
  'text-decoration-line',
  'text-decoration-skip-ink',
  'text-decoration-style',
  'text-decoration-thickness',
  'text-emphasis-color',
  'text-emphasis-position',
  'text-emphasis-style',
  'text-indent',
  'text-justify',
  'text-orientation',
  'text-overflow',
  'text-rendering',
  'text-shadow',
  'text-transform',
  'text-underline-offset',
  'text-underline-position',
  'transition-delay',
  'transition-duration',
  'transition-property',
  'transition-timing-function',
  'unicode-bidi',
  'user-select',
  'vector-effect',
  'white-space',
  'will-change',
  'word-break',
  'word-spacing',
  'writing-mode',
];

export const NO_GENERATE_CONTENT_ELEMENTS = REPLACED_ELEMENTS.concat(VOID_ELEMENTS);

export const PLACEHOLDER_ELEMENTS: SupportedElementTagName[] = ['input', 'textarea', 'span'];

export const SKIPPED_PROPERTIES = ['-webkit-locale', '--tridactyl'];

export const INLINE_SKIPPED_PROPERTIES = null;
